function Pagenation(settings){
    var defaultParam={
        pagenationEl:"#pagantion",
        visiblePages:3,
        url:"",
        data:{}
    };
    this.params = $.extend(defaultParam,settings);
}
Pagenation.prototype.init=function(){
    var _this = this;
    $(_this.params.pagenationEl).jqPaginator({
        totalPages: 1,
        visiblePages: _this.params.visiblePages,
        currentPage: 1,
        first: '<li class="first"><a href="javascript:void(0);">第一页</a></li>',
        prev: '<li class="prev"><a href="javascript:void(0);">前一页</a></li>',
        next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
        last: '<li class="last"><a href="javascript:void(0);">最后一页</a></li>',
        page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
        onPageChange:function (num) {
            _this.params.data.pageNum=num
            $.ajax({
                "url":_this.params.url,
                "method":"post",
                "data":_this.params.data,
                "success":function(resp){
                    var temp = $("#template").html();
                    var content = Mustache.render(temp,{items:resp.data});
                    $("#content").html(content);
                    $("#pagantion").jqPaginator("option",{
                        totalPages:resp.data.totalPage
                    })
                }
            });
        }
    });
}

function AjaxUtils(options){
    this.options = {
        url:"",
        method:"POST",
        data:{},
        successCallBack:function(resp){
            console.log(resp);
        }
    };
    this.options = Object.assign(this.options, options);//将设定参数和默认参数进行合并操作;

    AjaxUtils.prototype.executeRequest = function(){
        $.ajax({
            "url":this.options.url,
            "method":this.options.method,
            "data":this.options.data,
            "success":this.options.successCallBack,
            "error":function(resp){
                alert("请求后台失败，请联系管理员同志...")
            }
        })
    }
}


Date.prototype.format = function(format) {
    var o = {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(),    //day
        "h+" : this.getHours(),   //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
        "S" : this.getMilliseconds() //millisecond
    }
    if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
        (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)if(new RegExp("("+ k +")").test(format))
        format = format.replace(RegExp.$1,
            RegExp.$1.length==1 ? o[k] :
                ("00"+ o[k]).substr((""+ o[k]).length));
    return format;
}